]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/network: Improve a11y of wireless network items
authorLukáš Tyrychtr <ltyrycht@redhat.com>
Fri, 24 Mar 2023 10:02:33 +0000 (11:02 +0100)
committerMarge Bot <marge-bot@gnome.org>
Tue, 4 Apr 2023 17:19:55 +0000 (17:19 +0000)
This MR does the following:
* Allows a screen reader user to determine the currently connected network
* Allwos a screen reader to read the security status and signal strength

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2724>

js/ui/status/network.js

index e3b9a5d459bc058c2d2e129ab847214a1078aede..a1ef22bef0316a8285de2360039a258af2ec4718 100644 (file)
@@ -757,6 +757,10 @@ const WirelessNetwork = GObject.registerClass({
             'is-active', '', '',
             GObject.ParamFlags.READABLE,
             false),
+        'signal-strength': GObject.ParamSpec.uint(
+            'signal-strength', '', '',
+            GObject.ParamFlags.READABLE,
+            0),
     },
     Signals: {
         'destroy': {},
@@ -783,7 +787,7 @@ const WirelessNetwork = GObject.registerClass({
         this._securityType = NM.UtilsSecurityType.NONE;
     }
 
-    get _strength() {
+    get signal_strength() {
         return this._bestAp?.strength ?? 0;
     }
 
@@ -857,6 +861,7 @@ const WirelessNetwork = GObject.registerClass({
         ap.connectObject(
             'notify::strength', () => {
                 this.notify('icon-name');
+                this.notify('signal-strength');
                 this._updateBestAp();
             }, this);
         this._updateBestAp();
@@ -900,7 +905,7 @@ const WirelessNetwork = GObject.registerClass({
             return cmpAps;
 
         // place stronger connections first
-        const cmpStrength = other._strength - this._strength;
+        const cmpStrength = other.signal_strength - this.signal_strength;
         if (cmpStrength !== 0)
             return cmpStrength;
 
@@ -997,7 +1002,6 @@ class NMWirelessNetworkItem extends PopupMenu.PopupBaseMenuItem {
         icons.add_actor(this._secureIcon);
 
         this._label = new St.Label();
-        this.label_actor = this._label;
         this.add_child(this._label);
 
         this._selectedIcon = new St.Icon({
@@ -1020,11 +1024,30 @@ class NMWirelessNetworkItem extends PopupMenu.PopupBaseMenuItem {
             GObject.BindingFlags.SYNC_CREATE,
             (bind, source) => [true, source ? 'network-wireless-encrypted-symbolic' : ''],
             null);
+        this._network.connectObject(
+            'notify::is-active', () => this._isActiveChanged(),
+            'notify::secure', () => this._updateAccessibleName(),
+            'notify::signal-strength', () => this._updateAccessibleName(),
+            this);
     }
 
     get network() {
         return this._network;
     }
+
+    _isActiveChanged() {
+        if (this._network.is_active)
+            this.add_accessible_state(Atk.StateType.CHECKED);
+        else
+            this.remove_accessible_state(Atk.StateType.CHECKED);
+    }
+
+    _updateAccessibleName() {
+        const secureString = this._network.secure ? _('Secure') : _('Not secure');
+        let signalStrengthString = _('Signal strength %s%%').format(this._network.signal_strength);
+        // translators: The first placeholder is the network name, the second and indication whether it is secure, and the last the signal strength indication
+        this.accessible_name = _('%s, %s, %s').format(this._label.text, secureString, signalStrengthString);
+    }
 });
 
 const NMWirelessDeviceItem = GObject.registerClass({